/*******************************************************************************
 * Copyright 2011 Towee.net
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *******************************************************************************/

package net.towee.model.account;

import java.util.Date;
import java.util.List;

import net.towee.model.Settings;
import net.towee.model.utils.Pair;

import com.google.gwt.user.client.rpc.IsSerializable;

/**
 * This interface define basic account data, consists of profile, attached accounts,
 * groups where user entered, password, email, account identity, boards. 
 * 
 * @author c58
 */
public interface AccountData extends IsSerializable {
	/**
	 * @return accountId Account identifier
	 */
	String getId();
	
	/**
	 * Cookie getters/setters
	 * @return
	 */
	String getCookieId();
	void setCookieId(String id);
	
	/**
	 * @return LoginzaAccountsContainer instance. It's a set of attached loginza accounts
	 */
	LoginzaAccountsContainer getAttachedAccounts();
	
	/**
	 * @return groups Groups where user entered
	 */
	AccountGroupsContainer getGroups();
	
	/**
	 * @return AccountIdentity object of user
	 */
	AccountIdentity getAccountIdentity();
	
	/**
	 * @return settings container
	 */
	Settings getSettingsContainer();
	
	/**
	 * @return accountProfile Account profile with some extended information about user
	 */
	AccountProfile getProfile();
	
	/**
	 * @return BoardsContainer consists of boards and minimized widgets
	 */
	BoardsContainer getBoardsContainer();
	
	/**
	 * @return AccountContacts with contacts of account
	 */
	ContactsContainer getContacts();
	
	/**
	 * @return pair of salt and digest for password verifying
	 */
	Pair<byte[], byte[]> getSaltDigest();
	void setSaltDigest(byte[] salt, byte[] digest);

	/**
	 * @return Email
	 */
	List<String> getEmails();
	
	/**
	 * Attach new email to account
	 * @param email
	 * @return TODO
	 */
	boolean addEmail(String email);
	
	/**
	 * Detach email from account
	 * @param email
	 */
	void removeEmail(String email);
	
	/** 
	 * @return registration date
	 */
	Date getRegDate();
	
	/**
	 * @return Date when user last session ended 
	 */
	Date getLastSessionDate();
	
	/**
	 * @return boolean If user registred in last session return true, otherwise false
	 */
	boolean isNew();
	
	/**
	 * Set new user when account created and unset in next session
	 * @param newUser
	 */
	void setNew(boolean newUser);
}
